﻿using System.Web.Mvc;
using Pay.DTO;
using Pay.IService;
using Pay.TO;



namespace Pay.Web.Areas.Admin.Controllers
{
    [RouteArea("admin")]
    [RoutePrefix("goodeclaration")]
    public class GoodDeclarationController : AdminController {
        private IGoodDeclarationService _iGoodDeclarationService;
        public GoodDeclarationController(IGoodDeclarationService iGoodDeclarationService) {
            _iGoodDeclarationService = iGoodDeclarationService;
        }

        /// <summary>
        /// 商品申报列表
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        public JsonResult Gets(GoodDeclarationQuery query) {
            var model = _iGoodDeclarationService.GetGoodDeclarations(query);
            return Json(ResultToJson.Json(model), JsonRequestBehavior.AllowGet);
        }

        /// <summary>
        /// 获取商品申报信息
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        public JsonResult Get(GoodDeclarationQuery query) {
            var model = _iGoodDeclarationService.GetGoodDeclaration(query);
            return Json(ResultToJson.Json(model), JsonRequestBehavior.AllowGet);
        }

        /// <summary>
        ///  商品编辑
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        public JsonResult Alter(good_declaration_dto dto) {
            var model = _iGoodDeclarationService.AlterGoodDeclaration(dto);
            return Json(ResultToJson.Json(model >= 0 ? "修改成功" : "修改失败", model), JsonRequestBehavior.AllowGet);
        }
        /// <summary>
        /// 商品审核
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        public JsonResult Audit(good_declaration_dto dto) {
            var model = _iGoodDeclarationService.AuditGoodDeclaration(dto);
            return Json(ResultToJson.Json(model >= 0 ? "操作成功" : "操作失败", model), JsonRequestBehavior.AllowGet);
        }
        /// <summary>
        /// 商品删除
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public JsonResult Delete(long id) {
            var model = _iGoodDeclarationService.DeleteGoodDeclaration(id);
            return Json(ResultToJson.Json(model >= 0 ? "删除成功" : "删除失败", model), JsonRequestBehavior.AllowGet);
        }
    }
}